package com.cl.mybatis.learn.day27;

import java.io.InputStream;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.cl.mybatis.learn.day27.bean.User;
import com.cl.mybatis.learn.day27.dao.UserMapper;

public class Mybatis001 {
    public static void main(String[] args) throws Exception {
        
        String resource = "common1/mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession session = sqlSessionFactory.openSession();
        
        UserMapper userMapper = session.getMapper(UserMapper.class);
        User user = new User();
        user.setId(6L);
        try {
            List<User> users = userMapper.selectAll(user);
        } finally {
            session.close();
        }
        
    }
}
